package com.bite.common.core.controller;

import cn.hutool.core.collection.CollectionUtil;
import com.bite.common.core.domain.R;
import com.bite.common.core.domain.TableDataInfo;
import com.github.pagehelper.PageInfo;

import java.util.List;

public class BaseController {

    public R<Void> toR(int rows){
        return rows>0?R.ok():R.fail();
    }
    public R<Void> toR(Boolean result){
        return result?R.ok():R.fail();
    }

    public TableDataInfo getTableDataInfo(List<?> list){
        if(CollectionUtil.isEmpty(list)){
            return TableDataInfo.empty();
        }
        //获取符合条件的总数->new PageInfo<>(list).getTotal()
        return TableDataInfo.success(list,new PageInfo<>(list).getTotal());
    }
}
